package com.jly.sqlSession;


import com.jly.config.XMLConfigBuilder;
import com.jly.pojo.Configuration;
import org.dom4j.DocumentException;

import java.beans.PropertyVetoException;
import java.io.InputStream;

public class SqlSessionFactoryBuilder {



    public SqlSessionFactory build(InputStream inputStream) throws PropertyVetoException, DocumentException {
        //1.dom4j解析配置文件，将中的内容封装到configuration中
        XMLConfigBuilder xmlConfigBuiler = new XMLConfigBuilder();

        Configuration configuration = xmlConfigBuiler.parseConfig(inputStream);

        //创建 SqlSessionFactory对象
        DefaultSqlSessionFactory defaultSqlSessionFactory = new DefaultSqlSessionFactory(configuration);

        return defaultSqlSessionFactory;
    }
}
